$(function () {
    $(".tab1").hide()
    $("#cpscgxsh").bootstrapTable({
        method:"post",
        contentType:'application/json',
        url:"/DFile/shlike",
        striped:true,
        pageNumber:1,
        pagination:true,
        sidePagination:'server',
        pageSize:3,
        pageList:[2,3,5,6],
        queryParams:function (parmes) {
            return{
                pageNum:(parmes.offset / parmes.limit) + 1,
                pageSize:parmes.limit,
            }
        },
        columns:[
            {title:"设计单编号",field:"designId",align:'center'},
            {title:"产品编号",field:"productId",align:'center'},
            {title:"产品名称",field:"productName",align:'center'},
            {title:"设计人",field:"designer",align:'center'},
            {title:"登记时间",field:"registerTime",align:'center'},
            {title:"工时总成本",field:"costPriceSum",align:'center'},
            {title:"审核",field:"designId",align:'center',
                formatter:function (value,row,index) {
                    var a="<a href='#' onclick='djsh("+JSON.stringify(row)+")'>审核</a>";
                    return a;
                }
            },
        ]
    })
})

//返回列表
function fanhui(){
    $("#div1").show();
    $(".tab1").hide();
}

function djsh(a) {
    $("#div1").hide();
    $(".tab1").show();

    $("#name").html(a.productName)
    $("#bh").html(a.productId)
    $("[name=designer]").val(a.designer)
    $("[name=moduleCostPriceSum]").html(a.costPriceSum)
    $("[name=registerTime]").html(a.registerTime)
    $("#comment").val(a.procedureDescribe)
    $("[name=register]").val(a.register)

    $("#gxtab").bootstrapTable({
        method: "post",
        contentType: 'application/json',
        url: "/DFile/gxmzlike/"+a.id,
        striped:true,
        pageNumber:1,
        pagination:false,
        pageSize:5,
        pageList:[5,6],
        queryParams:function (parmes) {
            return{
            }
        },
        columns: [
            {title: "序号", field: "detailsNumber", align: 'center'},
            {title: "工序名称", field: "procedureName", align: 'center'},
            {title: "工序编号", field: "procedureId", align: 'center'},
            {title: "描述", field: "procedureDescribe", align: 'center'},
            {title: "工时数", field: "labourHourAmount", align: 'center'},
            {title: "单位", field: "amountUnit", align: 'center'},
            {title: "单位工时成本", field: "costPrice", align: 'center',},
            {title: "工时成本小计", field: "subtotal", align: 'center',}
        ]
    })
}

function gxmxtg() {
    let cpbh = $("#bh").html();
    if (confirm("确定通过吗？")){
        $.ajax({
            type:"put",
            contentType:"application/json;charset:utf-8",
            url:"/DFile/tongguo/"+cpbh,
            dataType:"json",
            async:true,
            success:function (data) {
                $("#div1").show();
                $(".tab1").hide();
                $("#cpscgxsh").bootstrapTable("refresh");
            }
        })
    }
}

function gxmxbtg() {
    let cpbh = $("#bh").html();
    if (confirm("确定不通过吗？")){
        $.ajax({
            type:"put",
            contentType:"application/json;charset:utf-8",
            url:"/DFile/butongguo/"+cpbh,
            dataType:"json",
            async:true,
            success:function (data) {
                $("#div1").show();
                $(".tab1").hide();
                $("#cpscgxsh").bootstrapTable("refresh");
            }
        })
    }

}